extends Node2D

@export var body:PackedScene
@onready var shape_cast_2d: ShapeCast2D = $ShapeCast2D

var flag = true

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	pass

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _physics_process(delta: float) -> void:
	if flag:
		for i in range(100):
			var copy = body.instantiate() as RigidBody2D
			copy.name = str(i)
			add_child(copy)
			print(Util.check_have_obstacle(self,GameEnum.UtilObstacleCheckRange.AB,copy.collision_layer,Vector2(0,0),2,true).size())
		flag = false

#func _physics_process(delta: float) -> void:
	#if flag:
		#for i in range(100):
			#shape_cast_2d.target_position = Vector2(0,100)
			#shape_cast_2d.global_position = Vector2(0,0)
			#shape_cast_2d.force_shapecast_update()
			#if shape_cast_2d.get_collision_count()<1:
				#var copy = body.instantiate() as CharacterBody2D
				#copy.name = str(i)
				#add_child(copy)
			#else:
				#print("No")
			##print(Util.check_have_obstacle(self,GameEnum.UtilObstacleCheckRange.AB,copy.collision_layer,Vector2(0,0),2,true).size())
		#flag = false
